package com.sword.controller;

import com.sword.common.bean.Result;
import com.sword.pay.bean.bo.PayOrder;
import com.sword.pay.bean.enums.ChannelPayEnum;
import com.sword.pay.repository.AbsPayDriverStrategy;
import com.sword.pay.spring.SpringContextUtil;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @description: 控制类
 * @author：Lv.RJ
 * @version: 1.0.0
 * @create: 2025/02/17
 **/
@RestController
@RequestMapping("/sword")
public class SwordController {
    // 测试登录  ---- http://localhost:8081/sword/pay

    /* @RequestMapping("pay")
     public Result blueinvoice(@RequestParam("type")  String type) {*/
    @RequestMapping(value = "pay", method = RequestMethod.POST, consumes = "application/json")
    public Result blueinvoice(@RequestBody Map<String, String> params) {
        String type = params.get("type");
        // 你的逻辑

        AbsPayDriverStrategy driver = SpringContextUtil.create(ChannelPayEnum.ALIPAY.getCode(), AbsPayDriverStrategy.class);
//        AbsPayDriverStrategy driver = PayManager.getISInvoiceDriverRepository(ChannelPayEnum.ALIPAY, AbsPayDriverStrategy.class);
        PayOrder payOrder = new PayOrder();
        payOrder.setAppId(type);
        driver.initPayParam(payOrder, null, null);
        Result result = driver.doHandler();
        return result;
    }

}
